package com.wd.live.view.adapter

import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ActivityUtils.startActivity
import com.blankj.utilcode.util.ToastUtils
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.wd.live.R
import com.wd.live.model.bean.LM_QuerylistBean
import com.wd.live.model.bean.ZhiBoListBean


/**
 * 作者：马海钊
 * 时间：2023/8/18 11:48
 * 功能：收到连麦邀请
 */
class LiveRecyAdapter2(private val context: Context, private val list: LM_QuerylistBean) : RecyclerView.Adapter<LiveRecyAdapter2.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.lianmai_recy_xiao, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.name.text = list.result.get(position).nickName

        Glide.with(context!!)
            .load(list.result.get(position).headPic)
            .error(R.mipmap.xiao)
            .placeholder(R.mipmap.xiao)
            .apply(RequestOptions.bitmapTransform(RoundedCorners(20)))
            .into(holder.imgid)

        holder.button.setOnClickListener {
//            val intent = Intent(context, LookLiveActivity::class.java)
//            intent.putExtra("liveid", list.get(position).liveId)
//            startActivity(intent)
//            var cu=CustomDialog_four(context)
//            cu.show()
            ToastUtils.showLong("连麦成功")
        }


    }

    override fun getItemCount(): Int {
        return list.result.size
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var imgid: ImageView
        var name: TextView
        var button:Button
        init {
            imgid = itemView.findViewById(R.id.queryrecylist_xiao_imgid)
            name = itemView.findViewById(R.id.queryrecylist_xiao_name)
            button=itemView.findViewById(R.id.queryrecylist_xiao_button)
        }
    }
}